import Vue from 'vue'
import Router from 'vue-router'
const Index = () => import('@/views')
const Login = () => import('@/views/login')
const RechargeRecord = () => import('@/views/rechargeRecord')
const OrderManage = () => import('@/views/orderManage')
const AgencyManage = () => import('@/views/agencyManage')
const ResManage = () => import('@/views/resManage')
const ReportManage = () => import('@/views/reportManage')
const MemberManage = () => import('@/views/memberManage')
const BetsManage = () => import('@/views/betsManage')
const DrawManage = () => import('@/views/drawManage')
const DepositManage = () => import('@/views/depositManage')
const NoticeManage = () => import('@/views/noticeManage')
const AuthorityManage = () => import('@/views/authorityManage')
Vue.use(Router)
const router = new Router({
  routes: [
    { path: '/', name: 'login', component: Login },
    {
      path: '/',
      component: Index,
      redirect: '/home/rechargeRecord',
      children: [
        { name: 'rechargeRecord', path: '/home/rechargeRecord', component: RechargeRecord },
        { name: 'orderManage', path: '/home/orderManage', component: OrderManage },
        { name: 'agencyManage', path: '/home/agencyManage', component: AgencyManage },
        { name: 'resManage', path: '/home/resManage', component: ResManage },
        { name: 'reportManage', path: '/home/reportManage', component: ReportManage },
        { name: 'memberManage', path: '/home/memberManage', component: MemberManage },
        { name: 'betsManage', path: '/home/betsManage', component: BetsManage },
        { name: 'drawManage', path: '/home/drawManage', component: DrawManage },
        { name: 'depositManage', path: '/home/depositManage', component: DepositManage },
        { name: 'noticeManage', path: '/home/noticeManage', component: NoticeManage },
        { name: 'authorityManage', path: '/home/authorityManage', component: AuthorityManage }
      ]
    }
  ]
})
// router.beforeEach((to, from, next) => {
//   if (to.matched.some(res => res.meta.requireLogin)) {
//     if (window.localStorage.getItem('loginUserInfo')) {
//       let lifeTime = JSON.parse(window.localStorage.getItem('loginUserBaseInfo')).lifeTime * 1000
//       let nowTime = (new Date()).getTime()
//       if (nowTime < lifeTime) {
//         next()
//       } else {
//         this.$message.error('登录状态信息过期，请重新登录')
//         next({
//           path: '/login'
//         })
//       }
//     } else {
//       next({
//         path: '/login'
//       })
//     }
//   } else {
//     next()
//   }
// })
export default router
